package com.kaoker.system.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.kaoker.system.dao.IKeyNotePointDao;
import com.kaoker.system.entity.ExamPoint;
import com.kaoker.system.entity.Exercise;
import com.kaoker.system.entity.KeyNotePoint;
/**
 * DAO Interface implementation.
 * 
 * @author bladestone
 *
 */
public class KeyNotePointDao extends HibernateDaoSupport implements IKeyNotePointDao {

	@Override
	public void addKeyNotePoint(KeyNotePoint keyNotePoint) {
		 this.getHibernateTemplate().save(keyNotePoint);
	}

	@Override
	public void deleteKeyNotePoint(KeyNotePoint keyNotePoint) {
		 this.getHibernateTemplate().delete(keyNotePoint);
	}

	@Override
	public KeyNotePoint getKeyNotePoint(Long id) {
		return this.getHibernateTemplate().load(KeyNotePoint.class, id);
	}

	@Override
	public KeyNotePoint getKeyNotePoint(String name) {
		if (StringUtils.isBlank(name)) return null;
		
		String queryStr = "from KeyNotePoint where name=?" + name;
		return (KeyNotePoint)this.getHibernateTemplate().find(queryStr).get(0); 
	}

	//@Override
	public List<KeyNotePoint> getReferKeyNotePoints(KeyNotePoint keyNotePoint) {
		
		return null;
	}

	//@Override
	public List<ExamPoint> getReferExamPoints(KeyNotePoint keyNotePoint) {
		// TODO Auto-generated method stub
		return null;
	}

	//@Override
	public List<Exercise> getReferExercises(KeyNotePoint keyNotePoint) {
		if (ObjectUtils.equals(keyNotePoint, null)) return new ArrayList<Exercise>();
		 
		return null;
	}

	@Override
	public void updateKeyNotePoint(KeyNotePoint keyNotePoint) {
		 this.getHibernateTemplate().update(keyNotePoint);
	}

}
